package com.laputacastle.dr.mapper;

import com.laputacastle.dr.model.DemoRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

/**
* Created by Mybatis Generator 2019/11/26
*/
@Repository
public interface DemoRecordMapper {
    @Delete({
        "delete from t_dr_demorecord",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String cId);

    @InsertProvider(type=DemoRecordSqlProvider.class, method="insertSelective")
    int insertSelective(DemoRecord record);

    @Select({
        "select",
        "c_id, c_title, n_code, dt_create_time, dt_update_time, c_demo_md, c_demo_html",
        "from t_dr_demorecord",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="c_id", property="cId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="c_title", property="cTitle", jdbcType=JdbcType.VARCHAR),
        @Result(column="n_code", property="nCode", jdbcType=JdbcType.INTEGER),
        @Result(column="dt_create_time", property="dtCreateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="dt_update_time", property="dtUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="c_demo_md", property="cDemoMd", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="c_demo_html", property="cDemoHtml", jdbcType=JdbcType.LONGVARCHAR)
    })
    DemoRecord selectByPrimaryKey(String cId);

    @UpdateProvider(type=DemoRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DemoRecord record);

    @Update({
        "update t_dr_demorecord",
        "set c_title = #{cTitle,jdbcType=VARCHAR},",
          "n_code = #{nCode,jdbcType=INTEGER},",
          "dt_create_time = #{dtCreateTime,jdbcType=TIMESTAMP},",
          "dt_update_time = #{dtUpdateTime,jdbcType=TIMESTAMP},",
          "c_demo_md = #{cDemoMd,jdbcType=LONGVARCHAR},",
          "c_demo_html = #{cDemoHtml,jdbcType=LONGVARCHAR}",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(DemoRecord record);

    @Update({
        "update t_dr_demorecord",
        "set c_title = #{cTitle,jdbcType=VARCHAR},",
          "n_code = #{nCode,jdbcType=INTEGER},",
          "dt_create_time = #{dtCreateTime,jdbcType=TIMESTAMP},",
          "dt_update_time = #{dtUpdateTime,jdbcType=TIMESTAMP}",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(DemoRecord record);
}